<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="/js/vue2.min.js"></script>
    <script src="/js/axios.min.js"></script>
    <style>
        table.gridtable {
            font-family: verdana,arial,sans-serif;
            font-size:11px;
            color:#333333;
            border-width: 1px;
            border-color: #666666;
            border-collapse: collapse;
        }
        table.gridtable th {
            border-width: 1px;
            padding: 8px;
            border-style: solid;
            border-color: #666666;
            background-color: #dedede;
        }
        table.gridtable td {
            border-width: 1px;
            padding: 8px;
            border-style: solid;
            border-color: #666666;
            background-color: #ffffff;
        }
    </style>
</head>
<body>
<a href="addProject.html">添加</a>
<table id="project" class="gridtable">
    <tr>
        <th>序号</th>
        <th>项目id</th>
        <th>项目名称</th>
        <th>开始时间</th>
        <th>结束时间</th>
        <th>开发商名称</th>
        <th>承建商名称</th>
        <th>操作</th>
    </tr>
    <tr v-for="(item,index) in projectDto">
        <td>{{index}}</td>
        <td>{{item.pid}}</td>
        <td>{{item.pname}}</td>
        <td>{{item.starttime}}</td>
        <td>{{item.endtime}}</td>
        <td>{{item.developerName}}</td>
        <td>{{item.contractorName}}</td>
        <td>
            <a :href="'/editProject.html?pid='+item.pid" ><input type="button" title="编辑" value="编辑"/></a>
<!--            <input type="button" @click="editPro(item.pid)" value="编辑">-->
            <input type="button" @click="deletePro(item.pid)" value="删除">
        </td>
    </tr>
</table>


</body>
<script>
    app=new Vue({
        el : "#project",
        data : {
            projectDto:[]
        },
        methods : {
            deletePro:function(pid) {
                // alert("ssss")
                if (window.confirm("是否确实删除")){
                    axios.get("/project/deleteProject?pid="+pid).then(res=>{
                        if (res.data){
                            init();
                        }
                    })
                }
            },
            // editPro:function(pid) {
            //     axios.get("/project/findOne?pid="+pid).then(res=>{
            //         console.log(res)
            //     })
            // }
        }
    })
    window.onload =init();
        function init() {
        axios.get("/project/findAllDto").then(res=>{
            console.log(res)
            app.projectDto=res.data
        })
    }
</script>
</html>